<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('resource'); ?>
	<script type="text/javascript" src="<?php echo JS_DIR; ?>imgpreview.full.0.22.jquery.js"></script>
<?php $this->_endblock(); ?>
<?php $this->_block('title'); ?>
	Banner Manager
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>

<div id="content" class="box">
	<h1>Banner Manager</h1>
	<div id="menu" class="box">
		<ul class="box">
			<li><a href="<?php echo url('bannermanager/addoffer');?>"><span>Add</span></a></li>
		</ul>
	</div>
	<?php if (isset($infos)) 
			{
				foreach ($infos as $info)
				{
	?>
			<p class="msg info"><?php echo $info;?></p>
	<?php		}
			}
	?>
	<fieldset>
		<legend>Left Banner Offers</legend>
		<table class="full-size" style="text-align: center;">
			<thead>
				<tr>
					<th style="width:10%">Site</th>
					<th style="width:10%">Offer Name</th>
					<th style="width:10%">Partner Name</th>
					<th style="width:10%">Picture URL</th>
					<th style="width:10%">Link URL</th>
					<th style="width:10%">Start Date</th>
					<th style="width:10%">End Date</th>
					<th style="width:15%">Operate</th>
				</tr>
			</thead>
			<tbody>
				<?php 
					if (isset($leftBannerOffers) && count($leftBannerOffers) > 0):
						foreach($leftBannerOffers as $leftBannerOffer): 
				?>
					<tr>
						<td><?php echo $sites[$leftBannerOffer['site_id']]; ?></td>
						<td><?php echo $leftBannerOffer['offer_name']; ?></td>
						<td>
							<?php echo (isset($leftBannerOffer['is_partial']) && $leftBannerOffer['is_partial'] == 1)? '(Partial)' : ''; ?>
							<?php echo $leftBannerOffer['partner_name'];?>
						</td>
						<td><a class="imgPreview" href="<?php echo $leftBannerOffer['picture_url']; ?>">Preview</a></td>
						<td><a href="<?php echo $leftBannerOffer['link_url']; ?>" title="<?php echo $leftBannerOffer['link_url']; ?>" target="_blank">Click</a></td>
						<td><?php echo $leftBannerOffer['start_date'];?></td>
						<td><?php echo $leftBannerOffer['end_date'];?></td>
						<td>
							<a href="<?php echo url('bannermanager/update', array('id'=>$leftBannerOffer['id']));?>">Edit</a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/delete', array('id'=>$leftBannerOffer['id']));?>">Delete</a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/setdefault', array('id'=>$leftBannerOffer['id']));?>"><?php echo ($leftBannerOffer['is_default'] == 1)? 'Set Definition' : 'Set Default' ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/setactive', array('id'=>$leftBannerOffer['id']));?>"><?php echo ($leftBannerOffer['actived'] == 1)? 'Pause' : 'Active' ?></a>
						</td>
					</tr>
				<?php 
						endforeach; 
					endif;
				?>
			</tbody>
		</table>
	</fieldset>
	
	<fieldset>
		<legend>Right Banner Offers</legend>
		<table class="full-size" style="text-align: center;">
			<thead>
				<tr>
					<th style="width:10%">Site</th>
					<th style="width:10%">Offer Name</th>
					<th style="width:10%">Partner Name</th>
					<th style="width:10%">Picture URL</th>
					<th style="width:10%">Link URL</th>
					<th style="width:10%">Start Date</th>
					<th style="width:10%">End Date</th>
					<th style="width:15%">Operate</th>
				</tr>
			</thead>
			<tbody>
				<?php 
					if (isset($rightBannerOffers) && count($rightBannerOffers) > 0):
						foreach($rightBannerOffers as $rightBannerOffer): 
				?>
					<tr>
						<td><?php echo $sites[$rightBannerOffer['site_id']]; ?></td>
						<td><?php echo $rightBannerOffer['offer_name']; ?></td>
						<td>
							<?php echo (isset($rightBannerOffer['is_partial']) && $rightBannerOffer['is_partial'] == 1)? '(Partial)' : ''; ?>
							<?php echo $rightBannerOffer['partner_name'];?>
						</td>
						<td><a class="imgPreview" href="<?php echo $rightBannerOffer['picture_url']; ?>">Preview</a></td>
						<td><a href="<?php echo $rightBannerOffer['link_url']; ?>" title="<?php echo $rightBannerOffer['link_url']; ?>" target="_blank">Click</a></td>
						<td><?php echo $rightBannerOffer['start_date'];?></td>
						<td><?php echo $rightBannerOffer['end_date'];?></td>
						<td>
							<a href="<?php echo url('bannermanager/update', array('id'=>$rightBannerOffer['id']));?>">Edit</a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/delete', array('id'=>$rightBannerOffer['id']));?>">Delete</a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/setdefault', array('id'=>$rightBannerOffer['id']));?>"><?php echo ($rightBannerOffer['is_default'] == 1)? 'Set Definition' : 'Set Default' ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="<?php echo url('bannermanager/setactive', array('id'=>$rightBannerOffer['id']));?>"><?php echo ($rightBannerOffer['actived'] == 1)? 'Pause' : 'Active' ?></a>
						</td>
					</tr>
				<?php 
						endforeach; 
					endif;
				?>
			</tbody>
		</table>
	</fieldset>
</div>

<script>
$(function(){
	$('.imgPreview').imgPreview();
});
</script>
<?php $this->_endblock(); ?>